#include "widget.h"
#include "ui_widget.h"
#include "QProcess"
#include <iostream>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // 连接信号与槽  谁发出信号 发出什么信号 谁处理信号 怎么处理
    connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(on_pushButton_clicked()));
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    // 获取lineEdit数据
    QString program = ui->lineEdit->text();
    // 创建process对象
    QProcess* myProcess = new QProcess(this);
    std::cout << "LineEdit input:" << program.toStdString() << std::endl;
    myProcess->start(program);
}

void Widget::on_lineEdit_returnPressed()
{

}

void Widget::on_pushButton_2_clicked()
{
    this->close();
}
